/*--------------------------------------------------------------------------------*/
#ifndef __STACK__
#define __STACK__
/*--------------------------------------------------------------------------------*/
#include "primitives.h"
#include "object.h"
#include "util.h"
#include "debug.h"
#include <stack>
/*--------------------------------------------------------------------------------*/
template< class _CLASS_ >
class STACK
{

	// -- PUBLIC

public:

    // .. CONSTRUCTORS

    STACK() : Stack()
    {

    }

    ~STACK()
    {
     
    }

    // .. METHODS

    VOID Push( const _CLASS_ & object )
    {
    	Stack.push( object );
    }
    
    const _CLASS_ & Pop() const
    {
    	const _CLASS_
    		& object = Stack.top();
    		
		Stack.pop();
    		
    	return object;
    }
    
    _CLASS_ & Pop()
    {
    	_CLASS_
    		& object = Stack.top();
    		
    	Stack.pop();
    	
    	return object;
    }

    VOID Clear()
    {
        while( Stack.size() )
        {
        	Stack.pop();
        }
    }
    
    const _CLASS_ & GetTop() const
    {
    	return Stack.top();
    }
    
    _CLASS_ & GetTop()
    {
  		
    	return Stack.top();
    }  

    COUNT GetItemCount() const
    {
        return (COUNT)Stack.size();
    }
    
    BOOL IsEmpty() const
    {
    	return Stack.empty();
    }

    // -- PRIVATE

private :

    // .. ATTRIBUTES

    std::stack< _CLASS_ >
		Stack;
};
/*--------------------------------------------------------------------------------*/
#endif
